package com.ceba.test.base.dbdata.modules;
import com.ceba.base.dbdata.DataTableObject;
import com.ceba.base.dbdata.MysqlUtils;
public class UserDb {

	public static void init() throws Exception{
		//31-start
		DataTableObject u_user=new DataTableObject("u_user");
		u_user.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		u_user.addField("Tenant_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_user.addField("Name", "decimal(5,0)", "DEFAULT NULL", "", "false");
		u_user.addField("Mail", "decimal(5,0)", "DEFAULT NULL", "", "false");
		u_user.addField("Password", "int(11)", "DEFAULT '0'", "", "false");
		u_user.addField("Home_Address","varchar(200)"," DEFAULT NULL","","false");
		u_user.addField("Home_Telephone","varchar(32)"," DEFAULT NULL","","false");
		u_user.addField("Company_Address","varchar(200)","DEFAULT NULL","","false");
		u_user.addField("Company_Telephone","varchar(32)"," DEFAULT NULL","","false");
		u_user.addField("Mobile","varchar(32)","DEFAULT NULL","","false");
		u_user.addField("Remark","varchar(500)"," DEFAULT NULL","","false");
		u_user.addField("RowState","int(19)","DEFAULT NULL","","false");
		u_user.addField("Last_Active_Time","datetime","DEFAULT NULL","","false");
		u_user.addField("department_ID","varchar(32)","DEFAULT NULL","","false");
		u_user.addField("Sex","bigint(20)","DEFAULT NULL","","false");
		u_user.addField("Fax","varchar(50)","DEFAULT NULL","","false");
		u_user.addField("Birthday","datetime","DEFAULT NULL","","false");
		u_user.addField("Card_ID","varchar(150)"," DEFAULT NULL","","false");
		u_user.addField("Education","bigint(20)"," DEFAULT NULL","","false");
		u_user.addField("Photo","varchar(300)"," DEFAULT NULL","","false");
		u_user.addField("MSN","varchar(300)"," DEFAULT NULL","","false");
		u_user.addField("QQ","varchar(150)","DEFAULT NULL","","false");
		u_user.addField("State","bigint(20)"," DEFAULT NULL","","false");
		u_user.addField("Create_Time","datetime","DEFAULT NULL","","false");
		u_user.addField("Create_User","varchar(32)","DEFAULT NULL","","false");
		u_user.addField("Login_ID", "varchar(32)","DEFAULT NULL","","false");
		u_user.addField("Item_Index", "int(11)","DEFAULT NULL","","false");
		u_user.addField("Nick","varchar(192)","DEFAULT NULL","","false");
		u_user.addField("Rank","bigint(20)","DEFAULT NULL","","false");
		u_user.addField("Title", "varchar(150)","DEFAULT NULL","","false");
		u_user.addField("Update_User","varchar(32)","DEFAULT NULL","","false");
		u_user.addField("Update_Time","datetime","DEFAULT NULL","","false");
		u_user.addField("Is_Online","int(11)"," DEFAULT NULL","","false");
		u_user.addField("CN","varchar(50)"," DEFAULT NULL","","false");
		u_user.addField("TYPE","int(11)","DEFAULT '0'","","false");
		u_user.addField("POSITION","int(11)","DEFAULT '0'","","false");
		u_user.addField("IS_LOCKED","int(11)","DEFAULT '0'","","false");
		u_user.addField("VERSION","varchar(200)","DEFAULT '0'","","false");
		u_user.addField("DATAVERSION","varchar(200)","DEFAULT '0'","","false");
		MysqlUtils.syncTableStructure(u_user);
		//end
		//27-start
		DataTableObject u_department=new DataTableObject("u_department");
		u_department.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		u_department.addField("Step", "varchar(150)", "DEFAULT NULL", "", "false");
		u_department.addField("Name", "varchar(150)", "DEFAULT NULL", "", "false");
		u_department.addField("Full_Name", "varchar(600)", "DEFAULT NULL", "", "false");
		u_department.addField("Data_Version", "decimal(19,0)", "DEFAULT NULL", "", "false");
		u_department.addField("Row_State", "int(11)", "DEFAULT NULL", "", "false");
		u_department.addField("Address", "varchar(1500)", "DEFAULT NULL", "", "false");
		u_department.addField("Tel", "varchar(150)", "DEFAULT NULL", "", "false");
		u_department.addField("Type", "bigint(20)", "DEFAULT NULL", "", "false");
		u_department.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		u_department.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department.addField("Item_Index", "int(11)", "DEFAULT '0'", "", "false");
		u_department.addField("State", "int(11)", "DEFAULT NULL", "", "false");
		u_department.addField("Fax", "varchar(150)", "DEFAULT NULL", "", "false");
		u_department.addField("Email", "varchar(300)", "DEFAULT NULL", "", "false");
		u_department.addField("Remark", "varchar(1500)", "DEFAULT NULL", "", "false");
		u_department.addField("Code", "varchar(150)", "DEFAULT NULL", "", "false");
		u_department.addField("Tenant_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department.addField("Area_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department.addField("PID", "varchar(50)", "DEFAULT NULL", "", "false");
		u_department.addField("DATAVERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		u_department.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(u_department);
		//end
		
		//29-start
		DataTableObject u_privilege=new DataTableObject("u_privilege");
		u_privilege.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		u_privilege.addField("User_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_privilege.addField("Flag", "varchar(200)", "DEFAULT NULL", "", "false");
		u_privilege.addField("Object_Id", "varchar(32)", "DEFAULT NULL", "", "false");
		u_privilege.addField("Action_Indexs", "bigint(20)", "NOT NULL DEFAULT '255'", "0", "false");
		u_privilege.addField("MAction_Indexs", "bigint(20)", "NOT NULL DEFAULT '255'", "0", "false");
		u_privilege.addField("TAction_Indexs", "bigint(20)", "NOT NULL DEFAULT '255'", "0", "false");
		u_privilege.addField("Version", "bigint(20)", "DEFAULT NULL", "", "false");
		u_privilege.addField("Action_Mode", "bigint(20)", "DEFAULT NULL", "", "false");
		u_privilege.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		u_privilege.addField("CREATE_USER", "varchar(150)", "DEFAULT NULL", "", "false");
		u_privilege.addField("ROW_STATE", "decimal(2,0)", "DEFAULT NULL", "", "false");
		u_privilege.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		u_privilege.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		u_privilege.addField("DATA_VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(u_privilege);
		//end
		
		//30-start
		DataTableObject u_role=new DataTableObject("u_role");
		u_role.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		u_role.addField("Tenant_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_role.addField("PID", "varchar(200)", "DEFAULT NULL", "", "false");
		u_role.addField("Application_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_role.addField("Name", "varchar(200)", "NOT NULL DEFAULT '255'", "0", "false");
		u_role.addField("LOGIN_INDEX", "varchar(2000)", "NOT NULL DEFAULT '255'", "0", "false");
		u_role.addField("Version", "int(20)", "DEFAULT NULL", "", "false");
		u_role.addField("Remark", "longtext", "DEFAULT NULL", "", "false");
		u_role.addField("Row_State", "int(20)", "DEFAULT NULL", "", "false");
		u_role.addField("State", "int(20)", "DEFAULT NULL", "", "false");
		u_role.addField("NO", "varchar(200)", "DEFAULT NULL", "", "false");
		u_role.addField("CREATE_USER", "varchar(32)", "NOT NULL DEFAULT '255'", "0", "false");
		u_role.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		u_role.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		u_role.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		u_role.addField("DATA_VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		u_role.addField("LOGIN_INDEX_SIGNVER", "varchar(1024)", "DEFAULT NULL", "", "false");
		u_role.addField("LOGIN_INDEX_SIGNONLY", "varchar(1024)", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(u_role);
		//end
		
	
		
		DataTableObject u_department_user=new DataTableObject("u_department_user");
		u_department_user.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		u_department_user.addField("User_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department_user.addField("department_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department_user.addField("ItemIndex", "int(4)", "DEFAULT '0'", "", "false");
		u_department_user.addField("Version", "int", "DEFAULT NULL", "", "false");
		u_department_user.addField("Post", "decimal(19,0)", "DEFAULT NULL", "", "false");
		u_department_user.addField("IS_DEFAULT", "int(4)", "DEFAULT NULL", "", "false");
		u_department_user.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department_user.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		u_department_user.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		u_department_user.addField("DATA_VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		u_department_user.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(u_department_user);
			
		insertDefaultData();
		addIndex();
	}

	public static void insertDefaultData() throws Exception {
		//更新默认
		MysqlUtils.updateField("COR_STAMP_NAME", "ceba审核章", "ID='66280ff6a6084825bace34015a9ecebf'", "g_stamp");
		MysqlUtils.updateField("COR_STAMP_NAME", "ceba编制章", "ID='ae8f3402a89a4cea819071204434a408'", "g_stamp");
		MysqlUtils.updateField("COR_STAMP_NAME", "ceba签发章", "ID='e11b58c1694d41c68b823bdf980a18fa'", "g_stamp");
		/*添加上传模板*/
		MysqlUtils.insertDataIntoTable("templates_word","(ID,WORD_GENERATE_NAME,WORD_NAME,WORD_VIRTUAL_PATH)","ID","1","'1', 'testTemplate.doc', 'testTemplate.doc', 'upfile/template/testTemplate.doc'");
		/**测试印章**/
		MysqlUtils.insertDataIntoTable("g_stamp","(ID,USER_ID,RELACTION_ID,FILE_ID,MATCH_NAME,IMG_WIDTH,IMG_HEIGHT,FILE_PATH,COR_FLAG,COR_STAMP_NAME,STAMP_X,STAMP_Y,STAMP_PAGE)","ID","1","'1', null, null, null, '$印章$', '75', '75', 'upfile/images/sign.png', '1', '测吧印章', '0', '0','1'");
		
		//管理员
		MysqlUtils.insertDataIntoTable("u_user","(ID,NAME,Password,Login_ID,IS_LOCKED)","ID","999999999999999999999999999999","'999999999999999999999999999999',  '系统管理员', 'H2NoRlsDs5sMhBLHxMarvQ==', 'admin', '0'");
		//加密员
		MysqlUtils.insertDataIntoTable("u_user","(ID,NAME,Password,Login_ID,IS_LOCKED)","ID","8c1ec0311e4c4881b49190ff84460c16","'8c1ec0311e4c4881b49190ff84460c16', '王乐', '4HxTGNNQUdzLUhB6cKo1qg==', 'wangle', '0'");
		//作废人
		MysqlUtils.insertDataIntoTable("u_user","(ID,NAME,Password,Login_ID,IS_LOCKED)","ID","verAdmin","'verAdmin', '验证平台管理员', '4HxTGNNQUdzLUhB6cKo1qg==', 'verAdmin', '0'");
		
		//加密员角色
		MysqlUtils.insertDataIntoTable("u_role","(ID,PID,Name,LOGIN_INDEX,Row_State,LOGIN_INDEX_SIGNVER,LOGIN_INDEX_SIGNONLY)","ID","109","'109', '0', '数字加密员', 'rms/modules/report/digitSignList.jsp', '1', 'rms/modules/signver/digitSignList.jsp', 'rms/modules/signonly/signManage.jsp'");
		//作废角色
		MysqlUtils.insertDataIntoTable("u_role","(ID,PID,Name,LOGIN_INDEX,Row_State,LOGIN_INDEX_SIGNVER,LOGIN_INDEX_SIGNONLY)","ID","200","'200', '0', '验证平台管理员', 'rms/modules/cnca/upInvalidReportCNCAList-FES.jsp', '1', NULL,'rms/modules/cnca/cncaReportList.jsp'");
		
		/**添加角色和人员之间关系***/
		MysqlUtils.insertDataIntoTable("u_privilege"," (ID,User_ID,Flag,Object_Id,Action_Indexs,MAction_Indexs,TAction_Indexs)","ID","f84eb62ef18d4b4d94dc862463276ddd","'f84eb62ef18d4b4d94dc862463276ddd', '8c1ec0311e4c4881b49190ff84460c16', '1', '109', '255', '255', '255'");
		MysqlUtils.insertDataIntoTable("u_privilege"," (ID,User_ID,Flag,Object_Id,Action_Indexs,MAction_Indexs,TAction_Indexs)","ID","verAdmin","'verAdmin', 'verAdmin', '1', '200', '255', '255', '255'");
	}

	//添加索引
	public static void addIndex() throws Exception {
	}
}
